<?php

	if (isset($_POST['editer'])) 
	{
		$req = $bdd->query('SELECT pj_fiches.nom AS nom,pj_fiches.pj_race_id AS id FROM pj_fiches, pj_races WHERE pj_fiches.id = :id');
		?>
		<table>
		<tr><th>Nom PJ</th><th>Propriétaire</th><th></th></tr>
		<?php
		while ($donnees = $req->fetch())
		{
			?>
			<tr>
			<td><input type="text" name="nom" value="<?php echo $donnees['nom']; ?>" maxlength="250" size="30">
			<input type="hidden" value="<?php echo $donnees['id']; ?>">
			</td>
			<td><input type="text" name="identifiant" value="<?php echo $donnees['identifiant']; ?>" maxlength="250" size="15"></td>
			<td>..</td>
			</tr>
			<?php
		}
		?>
		</table>
		<?php
		$req->closeCursor();
	}
?>
	
	<h1 id="titre">Gestion des personnages</h1>

	<p>
	<form method="post" action="page.php?page=admin_personnages">
		<?php
		$req = $bdd->query('SELECT membres.identifiant AS identifiant, pj_fiches.id AS id_pj, pj_fiches.nom AS nom FROM membres, pj_fiches ORDER BY membres.identifiant');

		?>
		<table>
		<tr><th>Nom PJ</th><th>Propriétaire</th><th></th></tr>
		<?php
		while ($donnees = $req->fetch())
		{
			?>
			<tr>
			<td><input type="text" name="nom" value="<?php echo $donnees['nom']; ?>" maxlength="250" size="30">
			<input type="hidden" value="<?php echo $donnees['id_pj']; ?>">
			</td>
			<td><input type="text" name="identifiant" value="<?php echo $donnees['identifiant']; ?>" maxlength="250" size="15"></td>
			<td><input type="submit" name="editer" value="Editer" /></td>
			</tr>
			<?php
		}
		?>
		</table>
		<?php
		$req->closeCursor();
		?>
	</form>

